package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import service.UserService;

/**
 * ClassName: UserController
 * Description:
 * date: 2019/11/18 16:10
 * Author Airson
 * Since JDK 1.8
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Reference
    private UserService userService;

    @RequestMapping("login")
    @ResponseBody
    public Result login(String username, String password){
        System.out.println("oms backend,user:"+username+" ,password:"+password);
        if (userService.login(username,password)){
            System.out.println("login ok!!!");
            return new Result(true, MessageConstant.ACTION_SUCCESS);
        }else{
            System.out.println("login fail");
            return new Result(false,MessageConstant.ACTION_FAIL);
        }
    }
}
